package com.itheima.book.controller.v1;


import com.itheima.book.service.BookService;
import com.itheima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/bookshelf")
@Api(value = "书架相关的接口",tags = "书架相关的接口")
public class BookShelfController {
    @Autowired
    private BookService bookService;
    /**
     * 获取用户书架的图书
     * @return
     */
    @GetMapping
    @ApiOperation("获取用户书架的图书")
    public ResponseResult getBookShelf() {
        return bookService.getBookShelf();
    }

    /**
     * 添加图书到书架
     * @param id
     * @return
     */
    @PostMapping("/{id}")
    @ApiOperation("添加图书到书架")
    public ResponseResult addToBookShelf(@PathVariable Integer id) {
        return bookService.addToBookShelf(id);
    }

    /**
     * 从书架移除图书
     * @param ids
     * @return
     */
    @DeleteMapping("")
    @ApiOperation("丛书架移除图书")
    public ResponseResult removeFromBookShelf(String[] ids) {
        return bookService.removeFromBookShelf(ids);
    }


}
